console.log(eval('2+2'));
console.log(eval(new String("2 + 2")));
console.log(eval('2 + 2') === eval('4'));

console.log('\x1b[31m------不要使用 eval ------------\x1b[0m');

function 除(x) {
    if(isFinite(1000/x)) {
        return '有限的';
    }
    return '无限的';
}
console.log(除(0));
console.log(除(1));

console.log('---------------------');

function 毫秒(x) {
    if(isNaN(x)) {
        return '不是一个数字';
    }
    return x * 1000;
}
console.log(毫秒('100F'));
console.log(毫秒('0.0314E+2'));

console.log('-------------------');

function 圆周长(半径) {
    return parseFloat(半径) * 2.0 * Math.PI;
}
console.log(圆周长(3));
console.log(圆周长('3'));
console.log(圆周长('abc'));

console.log('-----------------');

console.log(parseInt('123', 10) * 2);

console.log('---------------------');

const 网址 = 'https://mozilla.org/?x=abc你好шеллы';
const 加密 = encodeURI(网址);
console.log(加密);
try {
    console.log(decodeURI(加密));
}
catch(e) {
    console.error(e.message);
}
console.log(`?x=${encodeURIComponent('test?')}`);
console.log(`?x=${decodeURIComponent('test%3F')}`);